<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="dao.DaoBlog" %>
<%@ page import="java.sql.ResultSet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>显示所有博客</title>
</head>
<body>
<h1>显示所有博文</h1>
<div class="head">
<a href="showBlog.jsp" title="进入我的博客首页">欢迎<%=session.getAttribute("name")%></a>
<a href="" title="进入我的应用">进入我的应用</a>
</div>
<form method=post action="/blog.jsp" >
<table>
<tr><td>标题</td><td>作者</td><td>内容摘要</td></tr>
<!-- 遍历输出所有的博文 -->

<%
      //获得所有博文，遍历输出
      ResultSet set=new DaoBlog().getAllBlog();
      while(set.next()){
    	  String author=set.getString("name");
    	  String title=set.getString("title");
    	  String content=set.getString("sampleCon");//日志内容的简化
          session.setAttribute("title",title);
          //out.print("<tr><td><input type=\"text\"  name=\"title\"  value="+title+"></td><td>"+author+"</td><td>"+content+"</td></tr>");
          out.print("<tr><td><a href=blog.jsp>"+title+"</a></td><td>"+author+"</td><td>"+content+"</td></tr>");
      }

%>
</table>
</form>
</body>
</html>